<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      padding: 0;
      margin: 0;
    }

    .out {
      width: 1100px;
      margin: 0 auto;
      border: 1px solid red;
      overflow: hidden;
    }

    /* .out::after{
      content: "";
      display: block;
      clear: both;
    } */
    .out .box {
      width: 260px;
      height: 300px;
      background: #ddd;
      float: left;
      margin-bottom: 20px;
      margin-right: 20px;
    }

    .out .box:nth-child(4n) {
      margin-right: 0;
    }

    /* 移动优先原则 */
    @media(max-width:768px) {
      .out {
        width: 100%;
      }

      .out .box {
        width: 320px;
        float: none;
        margin-left: auto;
        margin-right: auto;
      }

      .out .box:nth-child(4n) {
        margin-right: auto;
      }
    }

    @media(min-width:768px) {
      .out {
        width: 680px;
      }

      .out .box {
        width: 320px;
        margin-right: 40px;
      }

      .out .box:nth-child(2n) {
        margin-right: 0;
      }

    }

    @media(min-width:992px) {
      .out {
        width: 960px;
      }

      .out .box {
        width: 290px;
        margin-right: 45px;
      }

      .out .box:nth-child(2n) {
        margin-right: 45px;
      }

      .out .box:nth-child(3n) {
        margin-right: 0px;
      }

    }

    @media(min-width:1200px) {
      .out {
        width: 1100px;
      }

      .out .box {
        width: 260px;
        margin-right: 20px;
      }

      .out .box:nth-child(2n) {
        margin-right: 20px;
      }

      .out .box:nth-child(3n) {
        margin-right: 20px;
      }

      .out .box:nth-child(4n) {
        margin-right: 0px;
      }


    }

    @media(min-width:1400px) {
      .out {
        width: 1300px;
      }

      .out .box {
        width: 300px;
        margin-right: 33.3333px;
      }

      .out .box:nth-child(2n) {
        margin-right: 33.3333px;
      }

      .out .box:nth-child(3n) {
        margin-right: 33.3333px;
      }

      .out .box:nth-child(4n) {
        margin-right: 0px;
      }

    }
  </style>
</head>

<body>
  <div class="out">
    <div class="box">1</div>
    <div class="box">2</div>
    <div class="box">3</div>
    <div class="box">4</div>
    <div class="box">5</div>
    <div class="box">6</div>
    <div class="box">7</div>
    <div class="box">8</div>
    <div class="box">9</div>
    <div class="box">10</div>
    <div class="box">11</div>
    <div class="box">12</div>
  </div>
</body>

</html>
